package com.financing.wap.util;

import java.math.BigDecimal;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;


public class CallJavaScriptUtil {
	public static void main(String[] args) throws ScriptException {
		String s="var a={bailAmount}; a/100*3000000";
		s=s.replace("{bailAmount}", new BigDecimal(0.3).toString());
		System.out.println(new BigDecimal(evalScriptStr(s)+"").setScale(2));
	}
	
	public static Object evalScriptStr(String scriptStr) throws ScriptException{
		ScriptEngineManager sem=new ScriptEngineManager();
		ScriptEngine engineByName = sem.getEngineByName("JavaScript");
		Object o= engineByName.eval(scriptStr);
		return o;
	}
	
}
